From 2675a5a40847fbc633031c89f82c33c2572dca2a Mon Sep 17 00:00:00 2001 From: David Banks Date: Sun, 14 Jun 2015 22:24:46 +0100 Subject: [PATCH] In AtomCpuMon generated Phi1 and Phi2 so the are non-overlapping by 40ns Change-Id: Id6c3500c221a46d9c6af022a7c710776b22ca196 --- .gitignore | 1 + AtomCpuMon.xise | 277 ++++++++++++++++++++++++++++++++++-------- firmware/Makefile.cpu | 55 +++++++++ src/AtomCpuMon.bmm | 38 ++++++ src/AtomCpuMon.ucf | 16 ++- src/AtomCpuMon.vhd | 141 +++++++++++++-------- 6 files changed, 417 insertions(+), 111 deletions(-) create mode 100644 firmware/Makefile.cpu create mode 100644 src/AtomCpuMon.bmm diff --git a/.gitignore b/.gitignore index 8921c1c..9484486 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ nohup.out AtomBusMon_guide.ncd AtomBusMon_summary.html src/AtomBusMon_bd.bmm +src/AtomCpuMon_bd.bmm *~ #* diff --git a/AtomCpuMon.xise b/AtomCpuMon.xise index 77d2f52..bcf217d 100644 --- a/AtomCpuMon.xise +++ b/AtomCpuMon.xise @@ -20,37 +20,249 @@ - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - @@ -64,8 +276,6 @@ - - @@ -83,13 +293,11 @@ - - @@ -100,7 +308,6 @@ - @@ -109,32 +316,26 @@ - - - + + - - - - - @@ -158,12 +359,9 @@ - - - @@ -181,10 +379,7 @@ - - - @@ -196,23 +391,20 @@ - - + - - + - @@ -243,20 +435,14 @@ - - - - - - @@ -267,13 +453,10 @@ - - - @@ -299,7 +482,6 @@ - @@ -307,9 +489,7 @@ - - @@ -325,8 +505,6 @@ - - @@ -352,25 +530,18 @@ - - - - - - - diff --git a/firmware/Makefile.cpu b/firmware/Makefile.cpu new file mode 100644 index 0000000..61b32d1 --- /dev/null +++ b/firmware/Makefile.cpu @@ -0,0 +1,55 @@ +# Paths that will need changing + +ATOMFPGA=$(HOME)/atom/AtomBusMon +PAPILIO_LOADER=/opt/GadgetFactory/papilio-loader/programmer +XILINX=/opt/Xilinx/14.7 + +# Shouldn't need to make changes below this point + +BIT_FILE=$(ATOMFPGA)/working/AtomCpuMon.bit +BMM_FILE=$(ATOMFPGA)/src/AtomCpuMon_bd.bmm + + +# Papilio dev environment +PROG=${PAPILIO_LOADER}/linux32/papilio-prog +BSCAN=${PAPILIO_LOADER}/bscan_spi_xc3s500e.bit +SREC_CAT=srec_cat +GAWK=gawk +DATA2MEM=${XILINX}/ISE_DS/ISE/bin/lin/data2mem + +# AVR dev environment +MCU=atmega103 +F_CPU=15855484 +CC=avr-gcc +OBJCOPY=avr-objcopy + +CFLAGS=-DF_CPU=${F_CPU}UL -DSERIAL_STATUS -DCOOKED_SERIAL -DNOUSART1 -mmcu=$(MCU) -Wall -Os -mcall-prologues + +OBJECTS=AtomBusMon.o hd44780.o status.o + +load: avr.bit +# sudo $(PROG) -v -f avr.bit +# sudo $(PROG) -v -b $(BSCAN) -f avr.bit -sa -r + +avr.bit: avr_progmem.mem + $(DATA2MEM) -bm $(BMM_FILE) -bd avr_progmem.mem -bt $(BIT_FILE) -o b avr.bit + +avr_progmem.mem: avr_progmem.hex + $(SREC_CAT) $< -Intel -Byte_Swap 2 -Data_Only -o tmp.mem -vmem 8 + $(GAWK) ' BEGIN{FS=" ";} { $$1= ""; print}' tmp.mem > $@ + rm tmp.mem + + +avr_progmem.hex : avr_progmem.out + $(OBJCOPY) -R .eeprom -O ihex avr_progmem.out avr_progmem.hex +avr_progmem.out : $(OBJECTS) + $(CC) $(CFLAGS) -o avr_progmem.out -Wl,-Map,avr_progmem.map $^ +%.o : %.c + $(CC) $(CFLAGS) -Os -c $< +%.o : %.S + $(CC) $(CFLAGS) -Os -c $< + +.phony: clean + +clean: + rm -f avr.bit avr_progmem.mem avr_progmem.hex avr_progmem.out avr_progmem.map *.o diff --git a/src/AtomCpuMon.bmm b/src/AtomCpuMon.bmm new file mode 100644 index 0000000..3b0f272 --- /dev/null +++ b/src/AtomCpuMon.bmm @@ -0,0 +1,38 @@ +ADDRESS_MAP avrmap PPC405 0 + + ADDRESS_SPACE rom_code RAMB16 [0x00000000:0x00003fff] + BUS_BLOCK + mon/Inst_AVR8/PM_Inst/RAM_Word0 [15:0]; + END_BUS_BLOCK; + + BUS_BLOCK + mon/Inst_AVR8/PM_Inst/RAM_Word1 [15:0]; + END_BUS_BLOCK; + + BUS_BLOCK + mon/Inst_AVR8/PM_Inst/RAM_Word2 [15:0]; + END_BUS_BLOCK; + + BUS_BLOCK + mon/Inst_AVR8/PM_Inst/RAM_Word3 [15:0]; + END_BUS_BLOCK; + + BUS_BLOCK + mon/Inst_AVR8/PM_Inst/RAM_Word4 [15:0]; + END_BUS_BLOCK; + + BUS_BLOCK + mon/Inst_AVR8/PM_Inst/RAM_Word5 [15:0]; + END_BUS_BLOCK; + + BUS_BLOCK + mon/Inst_AVR8/PM_Inst/RAM_Word6 [15:0]; + END_BUS_BLOCK; + + BUS_BLOCK + mon/Inst_AVR8/PM_Inst/RAM_Word7 [15:0]; + END_BUS_BLOCK; + + END_ADDRESS_SPACE; + +END_ADDRESS_MAP; \ No newline at end of file diff --git a/src/AtomCpuMon.ucf b/src/AtomCpuMon.ucf index 7321a6a..1a8214b 100644 --- a/src/AtomCpuMon.ucf +++ b/src/AtomCpuMon.ucf @@ -1,12 +1,12 @@ NET "clock49" LOC="P89" | IOSTANDARD = LVCMOS33 | PERIOD = 20.35ns ; # 49.152 MHz Oscillator -# NET "VSS" LOC="P16" | IOSTANDARD = LVCMOS33 ; # 6502 pin 1 -NET "Rdy" LOC="P95" | IOSTANDARD = LVCMOS33 ; # 6502 pin 2 +#NET "VSS" LOC="P16" | IOSTANDARD = LVCMOS33 ; # 6502 pin 1 +#NET "Rdy" LOC="P95" | IOSTANDARD = LVCMOS33 ; # 6502 pin 2 NET "Phi1" LOC="P18" | IOSTANDARD = LVCMOS33 ; # 6502 pin 3 -NET "IRQ_n" LOC="P17" | IOSTANDARD = LVCMOS33 ; # 6502 pin 4 +NET "IRQ_n" LOC="P17" | IOSTANDARD = LVCMOS33 | PULLUP ; # 6502 pin 4 #NET "NC" LOC="P94" | IOSTANDARD = LVCMOS33 ; # 6502 pin 5 -NET "NMI_n" LOC="P22" | IOSTANDARD = LVCMOS33 ; # 6502 pin 6 +NET "NMI_n" LOC="P22" | IOSTANDARD = LVCMOS33 | PULLUP ; # 6502 pin 6 NET "Sync" LOC="P23" | IOSTANDARD = LVCMOS33 ; # 6502 pin 7 #NET "VCC" LOC="P33" | IOSTANDARD = LVCMOS33 ; # 6502 pin 8 NET "Addr<0>" LOC="P32" | IOSTANDARD = LVCMOS33 ; # 6502 pin 9 @@ -58,6 +58,14 @@ NET tcclk LOC=P50 | IOSTANDARD = LVCMOS33 | DRIVE=16 ; #NET tm1 LOC=P42 | IOSTANDARD = LVCMOS33 | DRIVE=16 ; #NET thsw LOC=P99 | IOSTANDARD = LVCMOS33 | DRIVE=16 ; +NET "avr_TxD" LOC="P26" | IOSTANDARD = LVCMOS33 ; +NET "avr_RxD" LOC="P15" | IOSTANDARD = LVCMOS33 ; + +NET "trig<0>" LOC="P62" | IOSTANDARD = LVCMOS33 ; +NET "trig<1>" LOC="P63" | IOSTANDARD = LVCMOS33 ; + + + # NET "" LOC="P48" | IOSTANDARD = LVCMOS33 ; # connector pin E2 # NET "" LOC="P49" | IOSTANDARD = LVCMOS33 ; # connector pin E3 # NET "" LOC="P27" | IOSTANDARD = LVCMOS33 ; # connector pin E4 diff --git a/src/AtomCpuMon.vhd b/src/AtomCpuMon.vhd index 0bdf19b..d2fb47e 100644 --- a/src/AtomCpuMon.vhd +++ b/src/AtomCpuMon.vhd @@ -27,7 +27,7 @@ entity AtomCpuMon is clock49 : in std_logic; -- 6502 Signals - Rdy : in std_logic; + --Rdy : in std_logic; Phi0 : in std_logic; Phi1 : out std_logic; Phi2 : out std_logic; @@ -38,7 +38,14 @@ entity AtomCpuMon is R_W_n : out std_logic; Data : inout std_logic_vector(7 downto 0); SO_n : in std_logic; - Res_n : in std_logic; + Res_n : inout std_logic; + + -- External trigger inputs + trig : in std_logic_vector(1 downto 0); + + -- Serial Console + avr_RxD : in std_logic; + avr_TxD : out std_logic; -- GODIL Switches sw1 : in std_logic; @@ -57,73 +64,99 @@ entity AtomCpuMon is end AtomCpuMon; architecture behavioral of AtomCpuMon is - - signal Din : std_logic_vector(7 downto 0); signal Dout : std_logic_vector(7 downto 0); - signal dy_counter : std_logic_vector(31 downto 0); - signal dy_data : y2d_type ; signal R_W_n_int : std_logic; + signal Sync_int : std_logic; + signal Rdy_int : std_logic; signal Addr_int : std_logic_vector(15 downto 0); + signal IRQ_n_sync : std_logic; + signal NMI_n_sync : std_logic; + + signal Phi0_a : std_logic; + signal Phi0_b : std_logic; + signal Phi0_c : std_logic; + signal Phi0_d : std_logic; + signal cpu_clk : std_logic; + begin - - + mon : entity work.AtomBusMon port map ( + clock49 => clock49, + Addr => Addr_int, + Phi2 => Phi0, + RNW => R_W_n_int, + Sync => Sync_int, + Rdy => Rdy_int, + nRST => Res_n, + trig => trig, + lcd_rs => open, + lcd_rw => open, + lcd_e => open, + lcd_db => open, + avr_RxD => avr_RxD, + avr_TxD => avr_TxD, + sw1 => sw1, + nsw2 => nsw2, + led3 => led3, + led6 => led6, + led8 => led8, + tmosi => tmosi, + tdin => tdin, + tcclk => tcclk + ); - cpu : entity work.T65 port map ( - mode => "00", - Abort_n => '1', - SO_n => SO_n, - Res_n => Res_n, - Enable => '1', - Clk => not Phi0, - Rdy => Rdy, - IRQ_n => IRQ_n, - NMI_n => NMI_n, - R_W_n => R_W_n_int, - Sync => Sync, + cpu_t65 : entity work.T65 port map ( + mode => "00", + Abort_n => '1', + SO_n => SO_n, + Res_n => Res_n, + Enable => '1', + Clk => cpu_clk, + Rdy => Rdy_int, + IRQ_n => IRQ_n_sync, + NMI_n => NMI_n_sync, + R_W_n => R_W_n_int, + Sync => Sync_int, A(23 downto 16) => open, - A(15 downto 0) => Addr_int(15 downto 0), - DI(7 downto 0) => Din(7 downto 0), - DO(7 downto 0) => Dout(7 downto 0) - + A(15 downto 0) => Addr_int, + DI => Din, + DO => Dout ); + + sync_gen : process(cpu_clk, Res_n) + begin + if Res_n = '0' then + NMI_n_sync <= '1'; + IRQ_n_sync <= '1'; + elsif rising_edge(cpu_clk) then + NMI_n_sync <= NMI_n; + IRQ_n_sync <= IRQ_n; + end if; + end process; - Addr <= Addr_int; R_W_n <= R_W_n_int; - + Addr <= Addr_int; + Sync <= Sync_int; - Phi1 <= not Phi0; - Phi2 <= Phi0; - Din <= Data; + Data <= Dout when Phi0_d = '1' and R_W_n_int = '0' else (others => 'Z'); + + clk_gen : process(clock49) + begin + if rising_edge(clock49) then + Phi0_a <= Phi0; + Phi0_b <= Phi0_a; + Phi0_c <= Phi0_b; + Phi0_d <= Phi0_c; + end if; + end process; + + Phi1 <= not (Phi0_b or Phi0_d); + Phi2 <= Phi0_b and Phi0_d; + cpu_clk <= not Phi0_d; - Data <= Dout when R_W_n_int = '0' else (others => 'Z'); - -- OHO DY1 Display for Testing - inst_oho_dy1 : entity work.Oho_Dy1 port map ( - dy_clock => clock49, - dy_rst_n => '1', - dy_data => dy_data, - dy_update => '1', - dy_frame => open, - dy_frameend => open, - dy_frameend_c => open, - dy_pwm => "1010", - dy_counter => dy_counter, - dy_sclk => tdin, - dy_ser => tcclk, - dy_rclk => tmosi - ); - - dy_data(0) <= hex & "0000" & Addr_int(3 downto 0); - dy_data(1) <= hex & "0000" & Addr_int(7 downto 4); - dy_data(2) <= hex & "0000" & "00" & (not nsw2) & sw1; - - led3 <= not sw1; - led6 <= nsw2; - led8 <= RES_n; - end behavioral;