# test jump and beq puts "from ecomp add32.e bshift.e part2.e -o part2.net" puts "from esim < part2b.run > part2b.out" esim load part2.net # load up the instruction memory with 32 bit works # jump 3(0) will jump to location C that is esim 0x60 esim write -hex inst_mem.mr 0x0 32 08000003 # lw 1,4(0) branch slot, should be executed esim write -hex inst_mem.mr 0x20 32 80010004 # lw 2,8(0) should not get executed esim write -hex inst_mem.mr 0x40 32 80020008 # beq 0,3,3 jump should come here after doing lw 1,4(0) esim write -hex inst_mem.mr 0x60 32 04000003 # lw 3,0xC(0) branch slot, should get executed esim write -hex inst_mem.mr 0x80 32 8003000C # lw 4,0x10(0) should not get executed esim write -hex inst_mem.mr 0xA0 32 80040010 # lw 5,0x14(0) should not get executed esim write -hex inst_mem.mr 0xC0 32 80050014 # lw 6,0x18(0) should get executed esim write -hex inst_mem.mr 0xE0 32 80060018 # beq 0,1,3 should not branch esim write -hex inst_mem.mr 0x100 32 04010003 # ai 2,0(2) branch slot, always executed esim write -hex inst_mem.mr 0x120 32 C0020002 # lw 7,28(0) should get executed esim write -hex inst_mem.mr 0x140 32 8007001C # nop just padding esim write -hex inst_mem.mr 0x160 32 00000000 # nop just padding esim write -hex inst_mem.mr 0x180 32 00000000 # nop just padding esim write -hex inst_mem.mr 0x1A0 32 00000000 # # load register zero with zero, hopefully safe from software bug that # might change it esim write -hex greg.mr 0x0 32 00000000 # load data memory with 32 bit words esim write -hex dmem.mr 0x0 32 00112233 esim write -hex dmem.mr 0x20 32 11111111 esim write -hex dmem.mr 0x40 32 22222222 esim write -hex dmem.mr 0x60 32 33333333 esim write -hex dmem.mr 0x80 32 44444444 esim write -hex dmem.mr 0xA0 32 55555555 esim write -hex dmem.mr 0xC0 32 66666666 esim write -hex dmem.mr 0xE0 32 77777777 esim write -hex dmem.mr 0x100 32 88888888 # stop just before the first clock in order to print esim run 199 for {set i 13} {$i} {incr i -1} { puts "inst= [esim show -hex inst] at [esim curtime]ns" puts "ir_s1= [esim show -hex ir_s1] pc= [esim show -hex pc] at clock [esim show cntr]" puts "ir_s2= [esim show -hex ir_s2] a_s2= [esim show -hex a_s2] b_s2= [esim show -hex b_s2] c_s2= [esim show -hex c_s2]" puts "ir_s3= [esim show -hex ir_s3] a_s3= [esim show -hex a_s3] b_s3= [esim show -hex b_s3] rd_s3= [esim show rd_s3]" puts "ir_s4= [esim show -hex ir_s4] a_s4= [esim show -hex a_s4] b_s4= [esim show -hex b_s4] waiting=[esim events]\n" # stop just before the clock in order to print esim run 200 } # # dump registers and memory # output some general registers puts " General registers at end of simulation " puts "greg 0- 3= [esim read -hex greg.mr 0x0 32] [esim read -hex greg.mr 0x20 32] [esim read -hex greg.mr 0x40 32] [esim read -hex greg.mr 0x60 32]" puts "greg 4- 7= [esim read -hex greg.mr 0x80 32] [esim read -hex greg.mr 0xA0 32] [esim read -hex greg.mr 0xC0 32] [esim read -hex greg.mr 0xE0 32]" puts "greg 8-11= [esim read -hex greg.mr 0x100 32] [esim read -hex greg.mr 0x120 32] [esim read -hex greg.mr 0x140 32] [esim read -hex greg.mr 0x160 32]" puts "greg12-15= [esim read -hex greg.mr 0x180 32] [esim read -hex greg.mr 0x1A0 32] [esim read -hex greg.mr 0x1C0 32] [esim read -hex greg.mr 0x1E0 32]" # more output, data memory # puts "part2b.out finished"