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

Subversion Repositories zet86

[/] [zet86/] [trunk/] [sim/] [testbench.v] - Blame information for rev 49

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 zeus
`timescale 10ns/100ps
2
 
3
module testbench;
4
 
5
  // Net declarations
6 35 zeus
  wire [15:0] dat_o;
7
  wire [15:0] mem_dat_i, io_dat_i, dat_i;
8
  wire [19:1] adr;
9 2 zeus
  wire        we;
10 35 zeus
  wire        tga;
11
  wire [ 1:0] sel;
12 21 zeus
  wire        stb;
13 35 zeus
  wire        cyc;
14
  wire        ack, mem_ack, io_ack;
15 42 zeus
  wire        inta;
16 2 zeus
 
17 35 zeus
  reg         clk;
18
  reg         rst;
19 2 zeus
 
20 35 zeus
  reg  [15:0] io_reg;
21
 
22 42 zeus
  reg         intr;
23
 
24 2 zeus
  // Module instantiations
25 35 zeus
  memory mem0 (
26
    .wb_clk_i (clk),
27
    .wb_rst_i (rst),
28
    .wb_dat_i (dat_o),
29
    .wb_dat_o (mem_dat_i),
30
    .wb_adr_i (adr),
31
    .wb_we_i  (we),
32
    .wb_sel_i (sel),
33
    .wb_stb_i (stb & !tga),
34
    .wb_cyc_i (cyc & !tga),
35
    .wb_ack_o (mem_ack)
36
  );
37 2 zeus
 
38 14 zeus
  cpu cpu0 (
39 35 zeus
    .wb_clk_i (clk),
40
    .wb_rst_i (rst),
41
    .wb_dat_i (dat_i),
42
    .wb_dat_o (dat_o),
43
    .wb_adr_o (adr),
44
    .wb_we_o  (we),
45
    .wb_tga_o (tga),
46
    .wb_sel_o (sel),
47
    .wb_stb_o (stb),
48
    .wb_cyc_o (cyc),
49 42 zeus
    .wb_ack_i (ack),
50
    .wb_tgc_i (intr),
51
    .wb_tgc_o (inta)
52 14 zeus
  );
53
 
54 2 zeus
  // Assignments
55 35 zeus
  assign io_dat_i = (adr[15:1]==15'h5b) ? { io_reg[7:0], 8'h0 }
56
    : ((adr[15:1]==15'h5c) ? { 8'h0, io_reg[15:8] } : 16'h0);
57 42 zeus
  assign dat_i = inta ? 16'd3 : (tga ? io_dat_i : mem_dat_i);
58 2 zeus
 
59 35 zeus
  assign ack    = tga ? io_ack : mem_ack;
60
  assign io_ack = stb;
61
 
62 2 zeus
  // Behaviour
63
  // IO Stub
64 35 zeus
  always @(posedge clk)
65
    if (adr[15:1]==15'h5b && sel[1] && cyc && stb)
66
      io_reg[7:0] <= dat_o[15:8];
67
    else if (adr[15:1]==15'h5c & sel[0] && cyc && stb)
68
      io_reg[15:8] <= dat_o[7:0];
69 2 zeus
 
70
  always #1 clk = ~clk;
71
 
72 42 zeus
  initial
73 2 zeus
    begin
74 42 zeus
         intr <= 1'b0;
75 2 zeus
         clk <= 1'b1;
76
         rst <= 1'b0;
77
      #5 rst <= 1'b1;
78
      #2 rst <= 1'b0;
79 42 zeus
 
80
      #1000 intr <= 1'b1;
81
      @(posedge inta)
82
      @(posedge clk) intr <= 1'b0;
83 2 zeus
    end
84 14 zeus
 
85 2 zeus
endmodule

powered by: WebSVN 2.1.0

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