URL
https://opencores.org/ocsvn/socgen/socgen/trunk
Subversion Repositories socgen
[/] [socgen/] [trunk/] [Projects/] [opencores.org/] [Mos6502/] [ip/] [core/] [rtl/] [verilog/] [top.sim] - Rev 133
Compare with Previous | Blame | View Log
reg [7*8-1:0] A_instr;reg [10*8-1:0] A_state;reg [3*8-1:0] A_alu_mode;reg [3*8-1:0] A_alu_op_a_sel;reg [3*8-1:0] A_alu_op_b_inv;reg [3*8-1:0] A_alu_op_b_sel;reg [3*8-1:0] A_alu_op_c_sel;reg [4*8-1:0] A_alu_status_update;reg [3*8-1:0] A_dest;reg [7*8-1:0] A_ctrl;reg [8*8-1:0] A_cmd;reg [5*8-1:0] A_ins_type;reg [3*8-1:0] A_idx_sel;always@(posedge clk)beginif (enable && now_fetch_op)beginif(prog_counter[0])begin$display("%t %h %h %h",$realtime,prog_counter,prog_data[15:8],addr);endelsebegin$display("%t %h %h %h",$realtime,prog_counter,prog_data[7:0],addr);endendendalways @(*) begincase (state)`FETCH_OP: A_state = "FETCH_OP ";`EXECUTE: A_state = "EXECUTE ";`EXE_1: A_state = "EXE_1 ";`AXE_1: A_state = "AXE_1 ";`AXE_2: A_state = "AXE_2 ";`IDX_1: A_state = "IDX_1 ";`IDX_2: A_state = "IDX_2 ";`IDX_3: A_state = "IDX_3 ";`IDY_1: A_state = "IDY_1 ";`IDY_2: A_state = "IDY_2 ";`IDY_3: A_state = "IDY_3 ";`RESET: A_state = "RESET ";`HALT: A_state = "HALT ";`INT_2: A_state = "INT_2 ";`INT_1: A_state = "INT_1 ";default: A_state = "-XXXXXXXX-";endcaseendalways @(*) begincase (ir)`ADC_IMM:beginA_instr = "ADC_IMM";end`ADC_ZPG:beginA_instr = "ADC_ZPG";end`ADC_ZPX:beginA_instr = "ADC_ZPX";end`ADC_ABS:beginA_instr = "ADC_ABS";end`ADC_ABX:beginA_instr = "ADC_ABX";end`ADC_ABY:beginA_instr = "ADC_ABY";end`ADC_IDX:beginA_instr = "ADC_IDX";end`ADC_IDY:beginA_instr = "ADC_IDY";end`AND_IMM:beginA_instr = "AND_IMM";end`AND_ZPG:beginA_instr = "AND_ZPG";end`AND_ZPX:beginA_instr = "AND_ZPX";end`AND_ABS:beginA_instr = "AND_ABS";end`AND_ABX:beginA_instr = "AND_ABX";end`AND_ABY:beginA_instr = "AND_ABY";end`AND_IDX:beginA_instr = "AND_IDX";end`AND_IDY:beginA_instr = "AND_IDY";end`ASL_ACC:beginA_instr = "ASL_ACC";end`ASL_ZPG:beginA_instr = "ASL_ZPG";end`ASL_ZPX:beginA_instr = "ASL_ZPX";end`ASL_ABS:beginA_instr = "ASL_ABS";end`ASL_ABX:beginA_instr = "ASL_ABX";end`BCC_REL:beginA_instr = "BCC_REL";end`BCS_REL:beginA_instr = "BCS_REL";end`BEQ_REL:beginA_instr = "BEQ_REL";end`BIT_ZPG:beginA_instr = "BIT_ZPG";end`BIT_ABS:beginA_instr = "BIT_ABS";end`BMI_REL:beginA_instr = "BMI_REL";end`BNE_REL:beginA_instr = "BNE_REL";end`BPL_REL:beginA_instr = "BPL_REL";end`BRK_IMP:beginA_instr = "BRK_IMP";end`BVC_REL:beginA_instr = "BVC_REL";end`BVS_REL:beginA_instr = "BVS_REL";end`CLC_IMP:beginA_instr = "CLC_IMP";end`CLD_IMP:beginA_instr = "CLD_IMP";end`CLI_IMP:beginA_instr = "CLI_IMP";end`CLV_IMP:beginA_instr = "CLV_IMP";end`CMP_IMM:beginA_instr = "CMP_IMM";end`CMP_ZPG:beginA_instr = "CMP_ZPG";end`CMP_ZPX:beginA_instr = "CMP_ZPX";end`CMP_ABS:beginA_instr = "CMP_ABS";end`CMP_ABX:beginA_instr = "CMP_ABX";end`CMP_ABY:beginA_instr = "CMP_ABY";end`CMP_IDX:beginA_instr = "CMP_IDX";end`CMP_IDY:beginA_instr = "CMP_IDY";end`CPX_IMM:beginA_instr = "CPX_IMM";end`CPX_ZPG:beginA_instr = "CPX_ZPG";end`CPX_ABS:beginA_instr = "CPX_ABS";end`CPY_IMM:beginA_instr = "CPY_IMM";end`CPY_ZPG:beginA_instr = "CPY_ZPG";end`CPY_ABS:beginA_instr = "CPY_ABS";end`DEC_ZPG:beginA_instr = "DEC_ZPG";end`DEC_ZPX:beginA_instr = "DEC_ZPX";end`DEC_ABS:beginA_instr = "DEC_ABS";end`DEC_ABX:beginA_instr = "DEC_ABX";end`DEX_IMP:beginA_instr = "DEX_IMP";end`DEY_IMP:beginA_instr = "DEY_IMP";end`EOR_IMM:beginA_instr = "EOR_IMM";end`EOR_ZPG:beginA_instr = "EOR_ZPG";end`EOR_ZPX:beginA_instr = "EOR_ZPX";end`EOR_ABS:beginA_instr = "EOR_ABS";end`EOR_ABX:beginA_instr = "EOR_ABX";end`EOR_ABY:beginA_instr = "EOR_ABY";end`EOR_IDX:beginA_instr = "EOR_IDX";end`EOR_IDY:beginA_instr = "EOR_IDY";end`INC_ZPG:beginA_instr = "INC_ZPG";end`INC_ZPX:beginA_instr = "INC_ZPX";end`INC_ABS:beginA_instr = "INC_ABS";end`INC_ABX:beginA_instr = "INC_ABX";end`INX_IMP:beginA_instr = "INX_IMP";end`INY_IMP:beginA_instr = "INY_IMP";end`JMP_ABS:beginA_instr = "JMP_ABS";end`JMP_IND:beginA_instr = "JMP_IND";end`JSR_ABS:beginA_instr = "JSR_ABS";end`LDA_IMM:beginA_instr = "LDA_IMM";end`LDA_ZPG:beginA_instr = "LDA_ZPG";end`LDA_ZPX:beginA_instr = "LDA_ZPX";end`LDA_ABS:beginA_instr = "LDA_ABS";end`LDA_ABX:beginA_instr = "LDA_ABX";end`LDA_ABY:beginA_instr = "LDA_ABY";end`LDA_IDX:beginA_instr = "LDA_IDX";end`LDA_IDY:beginA_instr = "LDA_IDY";end`LDX_IMM:beginA_instr = "LDX_IMM";end`LDX_ZPG:beginA_instr = "LDX_ZPG";end`LDX_ZPY:beginA_instr = "LDX_ZPY";end`LDX_ABS:beginA_instr = "LDX_ABS";end`LDX_ABY:beginA_instr = "LDX_ABY";end`LDY_IMM:beginA_instr = "LDY_IMM";end`LDY_ZPG:beginA_instr = "LDY_ZPG";end`LDY_ZPX:beginA_instr = "LDY_ZPX";end`LDY_ABS:beginA_instr = "LDY_ABS";end`LDY_ABX:beginA_instr = "LDY_ABX";end`LSR_ACC:beginA_instr = "LSR_ACC";end`LSR_ZPG:beginA_instr = "LSR_ZPG";end`LSR_ZPX:beginA_instr = "LSR_ZPX";end`LSR_ABS:beginA_instr = "LSR_ABS";end`LSR_ABX:beginA_instr = "LSR_ABX";end`NOP_IMP:beginA_instr = "NOP_IMP";end`ORA_IMM:beginA_instr = "ORA_IMM";end`ORA_ZPG:beginA_instr = "ORA_ZPG";end`ORA_ZPX:beginA_instr = "ORA_ZPX";end`ORA_ABS:beginA_instr = "ORA_ABS";end`ORA_ABX:beginA_instr = "ORA_ABX";end`ORA_ABY:beginA_instr = "ORA_ABY";end`ORA_IDX:beginA_instr = "ORA_IDX";end`ORA_IDY:beginA_instr = "ORA_IDY";end`PHA_IMP:beginA_instr = "PHA_IMP";end`PHP_IMP:beginA_instr = "PHP_IMP";end`PLA_IMP:beginA_instr = "PLA_IMP";end`PLP_IMP:beginA_instr = "PLP_IMP";end`ROL_ACC:beginA_instr = "ROL_ACC";end`ROL_ZPG:beginA_instr = "ROL_ZPG";end`ROL_ZPX:beginA_instr = "ROL_ZPX";end`ROL_ABS:beginA_instr = "ROL_ABS";end`ROL_ABX:beginA_instr = "ROL_ABX";end`ROR_ACC:beginA_instr = "ROR_ACC";end`ROR_ZPG:beginA_instr = "ROR_ZPG";end`ROR_ZPX:beginA_instr = "ROR_ZPX";end`ROR_ABS:beginA_instr = "ROR_ABS";end`ROR_ABX:beginA_instr = "ROR_ABX";end`RTI_IMP:beginA_instr = "RTI_IMP";end`RTS_IMP:beginA_instr = "RTS_IMP";end`SBC_IMM:beginA_instr = "SBC_IMM";end`SBC_ZPG:beginA_instr = "SBC_ZPG";end`SBC_ZPX:beginA_instr = "SBC_ZPX";end`SBC_ABS:beginA_instr = "SBC_ABS";end`SBC_ABX:beginA_instr = "SBC_ABX";end`SBC_ABY:beginA_instr = "SBC_ABY";end`SBC_IDX:beginA_instr = "SBC_IDX";end`SBC_IDY:beginA_instr = "SBC_IDY";end`SEC_IMP:beginA_instr = "SEC_IMP";end`SED_IMP:beginA_instr = "SED_IMP";end`SEI_IMP:beginA_instr = "SEI_IMP";end`STA_ZPG:beginA_instr = "STA_ZPG";end`STA_ZPX:beginA_instr = "STA_ZPX";end`STA_ABS:beginA_instr = "STA_ABS";end`STA_ABX:beginA_instr = "STA_ABX";end`STA_ABY:beginA_instr = "STA_ABY";end`STA_IDX:beginA_instr = "STA_IDX";end`STA_IDY:beginA_instr = "STA_IDY";end`STX_ZPG:beginA_instr = "STX_ZPG";end`STX_ZPY:beginA_instr = "STX_ZPY";end`STX_ABS:beginA_instr = "STX_ABS";end`STY_ZPG:beginA_instr = "STY_ZPG";end`STY_ZPX:beginA_instr = "STY_ZPX";end`STY_ABS:beginA_instr = "STY_ABS";end`TAX_IMP:beginA_instr = "TAX_IMP";end`TAY_IMP:beginA_instr = "TAY_IMP";end`TXA_IMP:beginA_instr = "TXA_IMP";end`TYA_IMP:beginA_instr = "TYA_IMP";enddefault: A_instr = "XXX_XXX";endcaseendalways @(*) begincase (alu_mode)`alu_mode_add: beginA_alu_mode = "ADD";end`alu_mode_and: beginA_alu_mode = "AND";end`alu_mode_orr: beginA_alu_mode = "OR ";end`alu_mode_eor: beginA_alu_mode = "EOR";end`alu_mode_sfl: beginA_alu_mode = "SFL";end`alu_mode_sfr: beginA_alu_mode = "SFR";enddefault: beginA_alu_mode = "XXX";endendcaseend// alu_op_a_selalways @(*) begincase (alu_op_a_sel)`alu_op_a_00: beginA_alu_op_a_sel = "00 ";end`alu_op_a_acc: beginA_alu_op_a_sel = "ACC";end`alu_op_a_x : beginA_alu_op_a_sel = " X ";end`alu_op_a_y : beginA_alu_op_a_sel = " Y ";end`alu_op_a_ff : beginA_alu_op_a_sel = " FF ";end`alu_op_a_psr: beginA_alu_op_a_sel = "PSR";enddefault: beginA_alu_op_a_sel = "XXX";endendcaseend// alu_op_b_selalways @(*) begincase (alu_op_b_sel)`alu_op_b_00: beginA_alu_op_b_sel = " 0 ";end`alu_op_b_opnd: beginA_alu_op_b_sel = "OPR";end`alu_op_b_stk: beginA_alu_op_b_sel = "STK";end`alu_op_b_imm: beginA_alu_op_b_sel = "IMM";enddefault: beginA_alu_op_b_sel = "XXX";endendcaseend// alu_op_b_invalways @(*) begincase (alu_op_b_inv)1'b1: beginA_alu_op_b_inv = "INV";end1'b0: beginA_alu_op_b_inv = " ";enddefault: beginA_alu_op_b_inv = "XXX";endendcaseend// alu_op_c_selalways @(*) begincase (alu_op_c_sel)`alu_op_c_00: A_alu_op_c_sel = " 0 ";`alu_op_c_01: A_alu_op_c_sel = " 1 ";`alu_op_c_cin: A_alu_op_c_sel = "CIN";default: A_alu_op_c_sel = "XXX";endcaseend// alu_status_updatealways @(*) begincase (alu_status_update)`alu_status_update_none:beginA_alu_status_update = " ";end`alu_status_update_nz: beginA_alu_status_update = "N Z ";end`alu_status_update_nzc: beginA_alu_status_update = "N ZC";end`alu_status_update_nzcv:beginA_alu_status_update = "NVZC";end`alu_status_update_wr: beginA_alu_status_update = " WR ";end`alu_status_update_z67: beginA_alu_status_update = "76Z ";end`alu_status_update_res: beginA_alu_status_update = "RES ";enddefault: beginA_alu_status_update = "XXXX";endendcaseend// destalways @(*) begincase (dest)`dest_none: A_dest = " ";`dest_alu_a: A_dest = " A ";`dest_alu_x: A_dest = " X ";`dest_alu_y: A_dest = " Y ";`dest_mem: A_dest = "MEM";default: A_dest = "XXX";endcaseend// ctrlalways @(*) begincase (ctrl)`ctrl_none: A_ctrl = " ";`ctrl_jsr: A_ctrl = "JMP_SUB";`ctrl_jmp: A_ctrl = " JUMP ";`ctrl_jmp_ind: A_ctrl = "JMP_IND";`ctrl_brk: A_ctrl = " BREAK ";`ctrl_rti: A_ctrl = "RET INT";`ctrl_rts: A_ctrl = "RET SUB";`ctrl_branch: A_ctrl = "BRANCH ";default: A_ctrl = " -XXX- ";endcaseend// cmdalways @(*) begincase (cmd)`cmd_none: A_cmd = " ";`cmd_run: A_cmd = " RUN ";`cmd_load_add: A_cmd = "LOAD ADD";`cmd_load_vec: A_cmd = "LOAD VEC";default: A_cmd = " -XXX- ";endcaseend// ins_typealways @(*) begincase (ins_type)`ins_type_none: A_ins_type = " ";`ins_type_read: A_ins_type = "READ ";`ins_type_write: A_ins_type = "WRITE";`ins_type_rmw: A_ins_type = " RMW ";default: A_ins_type = "-XXX-";endcaseend// idx_selalways @(*) begincase (idx_sel)`idx_sel_00: A_idx_sel = " 0 ";`idx_sel_x: A_idx_sel = " X ";`idx_sel_y: A_idx_sel = " Y ";default: A_idx_sel = "---";endcaseend
