Line 44... |
Line 44... |
|
|
|
|
`timescale 1ns / 1ps
|
`timescale 1ns / 1ps
|
|
|
module t6507lp_fsm_tb();
|
module t6507lp_fsm_tb();
|
reg clk_in;
|
reg clk;
|
reg rst_in_n;
|
reg reset_n;
|
reg [7:0] alu_result;
|
reg [7:0] alu_result;
|
reg [7:0] alu_status;
|
reg [7:0] alu_status;
|
reg [7:0] data_in;
|
reg [7:0] data_in;
|
|
|
wire [12:0] address;
|
wire [12:0] address;
|
Line 59... |
Line 59... |
wire [7:0] alu_a;
|
wire [7:0] alu_a;
|
wire alu_enable;
|
wire alu_enable;
|
|
|
`include "../T6507LP_Package.v"
|
`include "../T6507LP_Package.v"
|
|
|
t6507lp_fsm #(8,13) my_dut(clk_in, rst_in_n, alu_result, alu_status, data_in, address, control, data_out, alu_opcode, alu_a, alu_enable);
|
t6507lp_fsm #(8,13) my_dut(clk, reset_n, alu_result, alu_status, data_in, address, control, data_out, alu_opcode, alu_a, alu_enable);
|
|
|
always #10 clk_in = ~clk_in;
|
always #10 clk = ~clk;
|
|
|
|
reg[7:0] fake_mem[20:0];
|
|
|
initial begin
|
initial begin
|
clk_in = 0;
|
clk = 0;
|
data_in = ASL_ACC;
|
reset_n = 1'b0;
|
rst_in_n = 1'b0;
|
alu_result = 8'h01;
|
alu_result = 0;
|
|
alu_status = 0;
|
alu_status = 0;
|
|
|
@(negedge clk_in) //will wait for next negative edge of the clock (t=20)
|
fake_mem[0] = ASL_ACC; // testing ACC mode
|
rst_in_n=1'b1;
|
fake_mem[1] = ADC_IMM; // testing IMM mode
|
|
fake_mem[2] = 8'h27;
|
|
fake_mem[3] = JMP_ABS; // testing ABS mode, JMP type
|
|
fake_mem[4] = 8'h09;
|
|
fake_mem[5] = 8'h00;
|
|
fake_mem[6] = ASL_ACC; // wont be executed
|
|
fake_mem[7] = ASL_ACC; // wont be executed
|
|
fake_mem[8] = ASL_ACC; // wont be executed
|
|
fake_mem[9] = ASL_ACC; // wont be executed
|
|
fake_mem[10] = LDA_ABS; // testing ABS mode, READ type. A = MEM[0002]. (a=27)
|
|
fake_mem[11] = 8'h02;
|
|
fake_mem[12] = 8'h00;
|
|
fake_mem[13] = ASL_ABS; // testing ABS mode, READ_MODIFY_WRITE type. should overwrite the first ASL_ACC
|
|
fake_mem[14] = 8'h04;
|
|
fake_mem[15] = 8'h00;
|
|
fake_mem[16] = 8'h00;
|
|
|
@(negedge clk_in) //will wait for next negative edge of the clock (t=40)
|
@(negedge clk) // will wait for next negative edge of the clock (t=20)
|
data_in = ROL_ACC;
|
reset_n=1'b1;
|
|
|
@(negedge clk_in) //will wait for next negative edge of the clock (t=60)
|
|
data_in = ROR_ACC;
|
|
|
|
@(negedge clk_in) //will wait for next negative edge of the clock (t=80)
|
#500;
|
@(negedge clk_in) //will wait for next negative edge of the clock (t=100)
|
|
@(negedge clk_in) //will wait for next negative edge of the clock (t=120)
|
|
$finish; // to shut down the simulation
|
$finish; // to shut down the simulation
|
end //initial
|
end //initial
|
|
|
|
always @(clk) begin
|
|
if (control == 0) begin // MEM_READ
|
|
data_in <= fake_mem[address];
|
|
$write("\nreading from mem position %h: %h", address, fake_mem[address]);
|
|
end
|
|
else if (control == 1'b1) begin // MEM_WRITE
|
|
fake_mem[address] <= data_out;
|
|
$write("\nreading from mem position %h: %h", address, fake_mem[address]);
|
|
end
|
|
end
|
|
|
endmodule
|
endmodule
|
|
|
No newline at end of file
|
No newline at end of file
|