signal read_strobe : std_logic;
signal interrupt : std_logic :='0';
signal interrupt_ack : std_logic;
signal reset : std_logic;
signal counter : std_logic_vector(7 downto 0);
signal HEX0 : std_logic_vector(3 downto 0);
signal HEX1 : std_logic_vector(3 downto 0);
signal HEX : std_logic_vector(3 downto 0);
signal sel : std_logic;
--
-------------------------------------------------------------------------
begin
processor: kcpsm3
port map( address => address,
instruction => instruction,
port_id => port_id,
write_strobe => write_strobe,
out_port => out_port,
read_strobe => read_strobe,
in_port => in_port,
interrupt => interrupt,
interrupt_ack => interrupt_ack,
reset => reset,
clk => clk);
program: int_test
port map( address => address,
instruction => instruction,
clk => clk);
-- Unused inputs on processor
in_port <= "00000000";
reset <= '0';
-- Adding the output registers to the processor
IO_registers: process(clk)
begin
if clk'event and clk='1' then
-- waveform register at address 02
if port_id(1)='1' and write_strobe='1' then
waveforms <= out_port;
end if;
-- Interrupt Counter register at address 04
if port_id(2)='1' and write_strobe='1' then
counter <= out_port;
end if;
-- sel port register at address 08
if port_id(3) = '1' and write_strobe = '1' then
sel <= out_port(0);
end if;
end if;
end process IO_registers;
-- Adding the interrupt input
-- Note that the initial value of interrupt (low) is
-- defined at signal declaration.
interrupt_control: process(clk)
begin
if clk'event and clk='1' then
if interrupt_ack='1' then
interrupt <= '0';
elsif interrupt_event='1' then
interrupt <= '1';
else
interrupt <= interrupt;
end if;
end if;
end process interrupt_control;
HEX0 <= counter(3 downto 0);
HEX1 <= counter(7 downto 4);
with HEX SELect
LED <= "0000110" when "0001", --1
"1011011" when "0010", --2
"1001111" when "0011", --3
"1100110" when "0100", --4
"1101101" when "0101", --5
"1111101" when "0110", --6
"0000111" when "0111", --7
"1111111" when "1000", --8
"1101111" when "1001", --9
"1110111" when "1010", --A
"1111100" when "1011", --b
"0111001" when "1100", --C
"1011110" when "1101", --d
"1111001" when "1110", --E
"1110001" when "1111", --F
"0111111" when others; --0
HEX <= HEX0 when sel = '0' else HEX1;
selp <= sel;
end Behavioral;
添加约束文件,约束文件内容如下。
NET "clk" LOC = "E12"|IOSTANDARD = LVCMOS33 ;
NET "selp" LOC = "AB19"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<6>" LOC = "AA19"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<5>" LOC = "AB21"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<4>" LOC = "AA21"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<3>" LOC = "V16"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<2>" LOC = "W16"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<1>" LOC = "V15"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "LED<0>" LOC = "V14"|IOSTANDARD = LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<0>" LOC ="R20"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<1>" LOC ="T19"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<2>" LOC ="U20"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<3>" LOC ="U19"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<4>" LOC ="V19"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<5>" LOC ="V20"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<6>" LOC ="Y22"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
NET "waveforms<7>" LOC ="W21"|IOSTANDARD=LVCMOS33|SLEW = SLOW|DRIVE = 8;
#PACE: Start of PACE Area Constraints
NET "interrupt_event" LOC = "T9"|IOSTANDARD = LVCMOS33|PULLUP ;
5. 综合、布局布线。如图12-31所示,在ISE中完成布局布线。

图12-31 综合、布局布线
6. 配置FPGA。用iMPACT配置FPGA。
7. 读者可以在/CH12/kcpsm3_int_test中找到ISE工程文件,在/CH12/assembler中找到int_test.psm源文件。
12.8 小结
本章介绍了PicoBlaze微控制器,包括其基本结构、指令系统和开发工具,最后用一个简单的实例介绍了PicoBlaze的开发流程。PicoBlaze具有精小、易用、灵活、高性能等优点,不会像很多MCU一样停产,影响产品生命周期,可以方便地应用在Xilinx的FPGA中,特别适合应用于小型的控制系统中,用来实现状态机控制,进行系统管理。
目前,FPGA已经广泛地应用在游戏机产品、小型电机控制和医疗产品中,希望通过本章介绍,使其应用更加广泛。
电子发烧友App


























评论