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

Subversion Repositories zet86

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

Go to most recent revision | 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
  wire [15:0] rd_data;
7
  wire [15:0] wr_data, mem_data, io_data;
8
  wire [19:0] addr;
9
  wire        we;
10
  wire        m_io;
11 14 zeus
  wire        byte_m;
12
  wire        ack_i;
13 21 zeus
  wire        stb;
14 2 zeus
 
15
  reg         clk, rst;
16
  reg [15:0]  io_reg;
17 14 zeus
  reg [ 1:0]  ack;
18 2 zeus
 
19
  // Module instantiations
20 21 zeus
  memory mem0 (clk, addr, wr_data, mem_data, stb & we & ~m_io, byte_m);
21 2 zeus
 
22 14 zeus
  cpu cpu0 (
23
    .clk_i  (clk),
24
    .rst_i  (rst),
25
    .dat_i  (rd_data),
26
    .dat_o  (wr_data),
27
    .adr_o  (addr),
28
    .we_o   (we),
29
    .mio_o  (m_io),
30
    .byte_o (byte_m),
31 21 zeus
    .stb_o  (stb),
32 14 zeus
    .ack_i  (ack_i)
33
  );
34
 
35 2 zeus
  // Assignments
36
  assign io_data = (addr[15:0]==16'hb7) ? io_reg : 16'd0;
37
  assign rd_data = m_io ? io_data : mem_data;
38 14 zeus
  assign ack_i   = (ack==2'b10);
39 2 zeus
 
40
  // Behaviour
41
  // IO Stub
42
  always @(posedge clk)
43 14 zeus
    if (addr==20'hb7 & we & m_io)
44 2 zeus
      io_reg <= byte_m ? { io_reg[15:8], wr_data[7:0] } : wr_data;
45
 
46
  always #1 clk = ~clk;
47 14 zeus
  always #2.13 ack = ack + 2'd1;
48 2 zeus
 
49
  initial
50
    begin
51
         clk <= 1'b1;
52
         rst <= 1'b0;
53 14 zeus
         ack <= 2'b0;
54 2 zeus
      #5 rst <= 1'b1;
55
      #2 rst <= 1'b0;
56
    end
57 14 zeus
 
58 2 zeus
endmodule

powered by: WebSVN 2.1.0

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