OpenCores
URL https://opencores.org/ocsvn/zet86/zet86/trunk

Subversion Repositories zet86

[/] [zet86/] [trunk/] [cores/] [zet/] [rtl/] [jmp_cond.v] - Blame information for rev 55

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 zeus
/*
2
 *  Copyright (c) 2008  Zeus Gomez Marmolejo <zeus@opencores.org>
3
 *
4
 *  This file is part of the Zet processor. This processor is free
5
 *  hardware; you can redistribute it and/or modify it under the terms of
6
 *  the GNU General Public License as published by the Free Software
7
 *  Foundation; either version 3, or (at your option) any later version.
8
 *
9 18 zeus
 *  Zet is distrubuted in the hope that it will be useful, but WITHOUT
10
 *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
 *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
12
 *  License for more details.
13 17 zeus
 *
14
 *  You should have received a copy of the GNU General Public License
15 18 zeus
 *  along with Zet; see the file COPYING. If not, see
16 17 zeus
 *  <http://www.gnu.org/licenses/>.
17
 */
18
 
19 2 zeus
`timescale 1ns/10ps
20
 
21
module jmp_cond (
22
    input [4:0]  logic_flags,
23
    input [3:0]  cond,
24
    input        is_cx,
25
    input [15:0] cx,
26
    output reg   jmp
27
  );
28
 
29
  // Net declarations
30
  wire of, sf, zf, pf, cf;
31
  wire cx_zero;
32
 
33
  // Assignments
34
  assign of = logic_flags[4];
35
  assign sf = logic_flags[3];
36
  assign zf = logic_flags[2];
37
  assign pf = logic_flags[1];
38
  assign cf = logic_flags[0];
39
  assign cx_zero = ~(|cx);
40
 
41
  // Behaviour
42
  always @(cond or is_cx or cx_zero or zf or of or cf or sf or pf)
43
    if (is_cx) case (cond)
44
        4'b0000: jmp <= cx_zero;         /* jcxz   */
45
        4'b0001: jmp <= ~cx_zero;        /* loop   */
46
        4'b0010: jmp <= zf & ~cx_zero;   /* loopz  */
47
        default: jmp <= ~zf & ~cx_zero; /* loopnz */
48
      endcase
49
    else case (cond)
50
      4'b0000: jmp <= of;
51
      4'b0001: jmp <= ~of;
52
      4'b0010: jmp <= cf;
53
      4'b0011: jmp <= ~cf;
54
      4'b0100: jmp <= zf;
55
      4'b0101: jmp <= ~zf;
56
      4'b0110: jmp <= cf | zf;
57
      4'b0111: jmp <= ~cf & ~zf;
58
 
59
      4'b1000: jmp <= sf;
60
      4'b1001: jmp <= ~sf;
61
      4'b1010: jmp <= pf;
62
      4'b1011: jmp <= ~pf;
63
      4'b1100: jmp <= (sf ^ of);
64
      4'b1101: jmp <= (sf ^~ of);
65
      4'b1110: jmp <= zf | (sf ^ of);
66
      4'b1111: jmp <= ~zf & (sf ^~ of);
67
    endcase
68
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.