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

Subversion Repositories zet86

[/] [zet86/] [trunk/] [cores/] [zet/] [rtl/] [exec.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
`include "defines.v"
22
 
23 21 zeus
module exec (
24
    // IO Ports
25
`ifdef DEBUG
26
    output [15:0] x,
27
    output [15:0] y,
28 27 zeus
    output [15:0] aluo,
29 45 zeus
    output [15:0] ax,
30
    output [15:0] dx,
31
    output [15:0] bp,
32
    output [15:0] si,
33
    output [15:0] es,
34
    output [15:0] c,
35
    output [ 3:0] addr_c,
36
    output [15:0] omemalu,
37
    output [ 3:0] addr_d,
38
    output [ 8:0] flags,
39 21 zeus
`endif
40
    input [`IR_SIZE-1:0] ir,
41
    input [15:0]  off,
42
    input [15:0]  imm,
43
    output [15:0] cs,
44
    output [15:0] ip,
45
    output        of,
46
    output        zf,
47
    output        cx_zero,
48
    input         clk,
49
    input         rst,
50
    input [15:0]  memout,
51 2 zeus
 
52 21 zeus
    output [15:0] wr_data,
53
    output [19:0] addr,
54
    output        we,
55
    output        m_io,
56
    output        byteop,
57 35 zeus
    input         block,
58 30 zeus
    output        div_exc,
59 42 zeus
    input         wrip0,
60
 
61
    output        ifl
62 21 zeus
  );
63 2 zeus
 
64
  // Net declarations
65 45 zeus
`ifndef DEBUG
66
  wire [15:0] c;
67
  wire [15:0] omemalu;
68
  wire [ 3:0] addr_c;
69
  wire [ 3:0] addr_d;
70
  wire  [8:0] flags;
71
`endif
72
  wire [15:0] a, b, s, alu_iflags, bus_b;
73 2 zeus
  wire [31:0] aluout;
74 45 zeus
  wire [3:0]  addr_a, addr_b;
75 2 zeus
  wire [2:0]  t, func;
76
  wire [1:0]  addr_s;
77 30 zeus
  wire        wrfl, high, memalu, r_byte, c_byte;
78 35 zeus
  wire        wr, wr_reg;
79 15 zeus
  wire        wr_cnd;
80
  wire        jmp;
81 35 zeus
  wire        b_imm;
82 45 zeus
  wire  [8:0] iflags, oflags;
83 15 zeus
  wire  [4:0] logic_flags;
84 30 zeus
  wire        alu_word;
85
  wire        a_byte;
86
  wire        b_byte;
87
  wire        wr_high;
88
  wire        dive;
89 2 zeus
 
90
  // Module instances
91 39 zeus
  alu     alu0( {c, a }, bus_b, aluout, t, func, alu_iflags, oflags,
92 30 zeus
               alu_word, s, off, clk, dive);
93 37 zeus
  regfile reg0 (
94
`ifdef DEBUG
95 45 zeus
    ax, dx, bp, si, es,
96 37 zeus
`endif
97
    a, b, c, cs, ip, {aluout[31:16], omemalu}, s, flags, wr_reg, wrfl,
98 30 zeus
                wr_high, clk, rst, addr_a, addr_b, addr_c, addr_d, addr_s, iflags,
99
                ~byteop, a_byte, b_byte, c_byte, cx_zero, wrip0);
100 15 zeus
  jmp_cond jc0( logic_flags, addr_b, addr_c[0], c, jmp);
101 2 zeus
 
102
  // Assignments
103
  assign addr_s = ir[1:0];
104
  assign addr_a = ir[5:2];
105
  assign addr_b = ir[9:6];
106
  assign addr_c = ir[13:10];
107
  assign addr_d = ir[17:14];
108
  assign wrfl   = ir[18];
109 14 zeus
  assign we     = ir[19];
110 2 zeus
  assign wr     = ir[20];
111 29 zeus
  assign wr_cnd = ir[21];
112 2 zeus
  assign high   = ir[22];
113
  assign t      = ir[25:23];
114
  assign func   = ir[28:26];
115
  assign byteop = ir[29];
116
  assign memalu = ir[30];
117
  assign m_io   = ir[32];
118
  assign b_imm  = ir[33];
119 30 zeus
  assign r_byte = ir[34];
120 2 zeus
  assign c_byte = ir[35];
121
 
122
  assign omemalu = memalu ? aluout[15:0] : memout;
123
  assign bus_b   = b_imm ? imm : b;
124
 
125
  assign addr = aluout[19:0];
126
  assign wr_data = c;
127 30 zeus
  assign wr_reg  = (wr | (jmp & wr_cnd)) && !block && !div_exc;
128
  assign wr_high = high && !block && !div_exc;
129 42 zeus
  assign of  = flags[8];
130
  assign ifl = flags[6];
131
  assign zf  = flags[3];
132 2 zeus
 
133
  assign iflags = oflags;
134 39 zeus
  assign alu_iflags = { 4'b0, flags[8:3], 1'b0, flags[2], 1'b0, flags[1],
135 2 zeus
                        1'b1, flags[0] };
136 15 zeus
  assign logic_flags = { flags[8], flags[4], flags[3], flags[1], flags[0] };
137 29 zeus
 
138 30 zeus
  assign alu_word = (t==3'b011) ? ~r_byte : ~byteop;
139
  assign a_byte = (t==3'b011 && func[1]) ? 1'b0 : r_byte;
140
  assign b_byte = r_byte;
141
  assign div_exc = dive && wr;
142 29 zeus
 
143 21 zeus
`ifdef DEBUG
144
  assign x        = a;
145
  assign y        = bus_b;
146 27 zeus
  assign aluo     = aluout;
147 21 zeus
`endif
148 2 zeus
endmodule

powered by: WebSVN 2.1.0

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