URL
https://opencores.org/ocsvn/zet86/zet86/trunk
[/] [zet86/] [trunk/] [sim/] [testbench.v] - Diff between revs 2 and 14
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 2 |
Rev 14 |
`timescale 10ns/100ps
|
`timescale 10ns/100ps
|
|
|
module testbench;
|
module testbench;
|
|
|
// Net declarations
|
// Net declarations
|
wire [15:0] rd_data;
|
wire [15:0] rd_data;
|
wire [15:0] wr_data, mem_data, io_data;
|
wire [15:0] wr_data, mem_data, io_data;
|
wire [19:0] addr;
|
wire [19:0] addr;
|
wire we;
|
wire we;
|
wire m_io;
|
wire m_io;
|
wire byte_m;
|
wire byte_m;
|
|
wire ack_i;
|
|
|
reg clk, rst;
|
reg clk, rst;
|
reg [15:0] io_reg;
|
reg [15:0] io_reg;
|
|
reg [ 1:0] ack;
|
|
|
// Module instantiations
|
// Module instantiations
|
memory mem0 (clk, addr, wr_data, mem_data, we & ~m_io, byte_m);
|
memory mem0 (clk, addr, wr_data, mem_data, we & ~m_io, byte_m);
|
cpu cpu0 (clk, rst, rd_data, wr_data, addr, we, m_io, byte_m,, 1'b1);
|
|
|
cpu cpu0 (
|
|
.clk_i (clk),
|
|
.rst_i (rst),
|
|
.dat_i (rd_data),
|
|
.dat_o (wr_data),
|
|
.adr_o (addr),
|
|
.we_o (we),
|
|
.mio_o (m_io),
|
|
.byte_o (byte_m),
|
|
.ack_i (ack_i)
|
|
);
|
|
|
// Assignments
|
// Assignments
|
assign io_data = (addr[15:0]==16'hb7) ? io_reg : 16'd0;
|
assign io_data = (addr[15:0]==16'hb7) ? io_reg : 16'd0;
|
assign rd_data = m_io ? io_data : mem_data;
|
assign rd_data = m_io ? io_data : mem_data;
|
|
assign ack_i = (ack==2'b10);
|
|
|
// Behaviour
|
// Behaviour
|
// IO Stub
|
// IO Stub
|
always @(posedge clk)
|
always @(posedge clk)
|
if (addr==20'hb7 & ~we & m_io)
|
if (addr==20'hb7 & we & m_io)
|
io_reg <= byte_m ? { io_reg[15:8], wr_data[7:0] } : wr_data;
|
io_reg <= byte_m ? { io_reg[15:8], wr_data[7:0] } : wr_data;
|
|
|
always #1 clk = ~clk;
|
always #1 clk = ~clk;
|
|
always #2.13 ack = ack + 2'd1;
|
|
|
initial
|
initial
|
begin
|
begin
|
clk <= 1'b1;
|
clk <= 1'b1;
|
rst <= 1'b0;
|
rst <= 1'b0;
|
|
ack <= 2'b0;
|
#5 rst <= 1'b1;
|
#5 rst <= 1'b1;
|
#2 rst <= 1'b0;
|
#2 rst <= 1'b0;
|
end
|
end
|
|
|
endmodule
|
endmodule
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.