układu sn74ls592 : http://focus.ti.com/lit/ds/symlink/sn74ls592.pdf
Oto poprawny kod w VHDL'u:
Kod: Zaznacz cały
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ls592 is
Port ( DIN : in std_logic_vector(7 downto 0);
RCK : in std_logic;
CLOAD : in std_logic;
CCK : in std_logic;
CCKEN : in std_logic;
CCLR : in std_logic;
RCO : out std_logic);
end ls592;
architecture Behavioral of ls592 is
signal rejestr: std_logic_vector(7 downto 0);
signal licznik: std_logic_vector(7 downto 0);
begin
load_reg: process (RCK,DIN)
begin
if rising_edge(RCK) then
rejestr<=DIN;
end if;
end process;
licz: process (CCK, CCKEN, CCLR, CLOAD)
begin
if CCLR='0' then
licznik<=(others=>'0');
elsif CLOAD='0' then
licznik<=rejestr;
elsif rising_edge(CCK) then
if CCKEN='0' then
licznik <= licznik + "00000001";
end if;
end if;
end process;
RCO<='0' when licznik=x"ff" else '1';
end Behavioral;
Kod: Zaznacz cały
module ls592 (DIN, RCK, CLOAD, CCK, CCKEN, CCLR,RCO);
input [7:0] DIN;
input RCK;
input CLOAD;
input CCK;
input CCKEN;
input CCLR;
output RCO;
wire [7:0] DIN;
wire RCK, CLOAD, CCK, CCKEN, CCLR, RCO;
reg [7:0] rejestr;
reg [7:0] licznik;
always @(posedge RCK)
rejestr<=DIN;
always @(CCK or CCKEN or CCLR or CLOAD)
begin
CCLR = 1'b0 ? licznik <= 1'b0;
else if (CLOAD == 1'b0)
licznik<=rejestr;
else if (CCK == 1'b1)
if (CCKEN == 1'b0)
licznik<=licznik+1;
end
//RCO<='0' when if licznik=x"ff" else '1';
licznik = 8'b11 ? RCO <= 1'b0 : 1'b1;
endmodule