wWarum wird nicht geschoben

(Firma: Unkown) #3649281
Lesenswert?

Hallo allerseits,

könnte einer oder der andere mir sagen, wo der fehler im folgenden Code 
ist

VAL_TMP muss zum buffer-Block geschoben werden und dann wird gespeichert

aber passiert nix

1
type state_command is ( idle , start_mess, finish_mess);
2
signal state, nextstatus : state_command; 
3

4
signal byte_count        : INTEGER RANGE 0 TO 7:=0;    -- Die zu empfangenden Bytes --
5
signal bit_count        : INTEGER RANGE 0 TO 10:=0;   -- Bits zum Byte (1Start-8DATA-2Stopp)--
6
signal trigger_count      : INTEGER RANGE 0 TO 9:=0;      -- trigger-Zähler um 10--
7
signal time_count        : INTEGER RANGE 0 TO 650:=0;   -- Vorwert zum Frqeuzenteiler 38,4kHz--
8
signal time_trigger_count  : INTEGER RANGE 0 TO 117:=0;   -- zeitliche trigger--
9
signal value_count      : INTEGER RANGE 0 TO 9:=0;     -- temporäres super Byte.--
10

11
signal synch_state      : STD_LOGIC :='0';
12
signal in_process        : STD_LOGIC := '0';         -- Status im Process--
13
signal start          : STD_LOGIC := '0';         -- Status los gehts--
14
signal check_bit        : STD_LOGIC := '0';         -- Kontrolle des ersten bit vom Datenstrom
15
signal finish          : STD_LOGIC := '0';         -- Status Ende
16
signal tmpValue        : STD_LOGIC_VECTOR(71 downto 0):= (others => '0'); -- Bitstream.
17
signal tmp_clk_out      : STD_LOGIC := '0';         -- Clock für LaRousse
18
signal CLK_LR_INIT      : STD_LOGIC :='0'; 
19
signal TMP_VAL_1        : STD_LOGIC_VECTOR(71 downto 0):= (others => '0');
20

21
begin
22

23
Clock_LR: Vorwzhl
24
Port map (
25
        Clk => CLK, 
26
        Rst => RESET,
27
        CTL_DOTO => CTL_TODO,
28
            ZClk => CLK_LR
29
      );
30

31

32
Process (CLK, RESET)
33
begin
34

35
if (RESET ='1') then
36
--    byte_count         <= 0;        
37
--    bit_count          <= 0;      
38
--    trigger_count      <= 0;    
39
--    time_count        <= 0;    
40
--    time_trigger_count  <= 0;
41
--    value_count        <= 0;
42
--    tmp_clk_out        <= '0';
43
--    in_process        <= '0';
44
--    finish          <= '0';
45
--    start            <= '0';
46
--    tmpValue          <= (others => '0');
47
--    tmp_clk_out        <= '0';
48
    state            <= idle;
49
elsif (rising_edge(CLK)) then
50
    state <= nextstatus;
51
end if;
52
end Process;
53

54
Process (CLK, DATA_IN)
55
begin
56

57
if (rising_edge(CLK)) then
58

59
      case state is
60
            when idle =>
61
                byte_count         <= 0;        
62
                bit_count          <= 0;      
63
                trigger_count      <= 0;  
64
                value_count        <= 0;
65
                in_process        <= '0';
66
                finish          <= '0';
67
                start            <= '0';
68
                tmpValue          <= (others => '0');
69
                CTL_STATE        <= "00";
70
                
71
                if (CTL_TODO = '1' and in_process = '0' and finish = '0') then
72
                    in_process <= '1';
73
                    nextstatus <= start_mess;
74
                end if;
75
                    
76
                
77
            when start_mess =>
78
                  CTL_STATE <= "10";--messung
79
                  start <='1';
80
                if (in_process = '1' and start ='1' and finish = '0') then
81
                  if (DATA_IN = '0') then
82
                      check_bit <= '1';
83
                  else
84
                  nextstatus <= idle;
85
                  end if;
86
                  if (check_bit = '1') then
87
                      trigger_count <= trigger_count+1;
88
                  end if;
89
                  if (trigger_count = 9) then
90
                      if (bit_count > 0 and bit_count < 8) then
91
                          tmpValue <= tmpValue(70 downto 0) & DATA_IN;
92
                          bit_count <= bit_count +1;
93
                        if (bit_count = 10) then
94
                          TMP_VAL_1 <= tmpValue;
95
                          trigger_count <= 0;
96
                          bit_count <= 0;
97
                          check_bit <= '0';
98
                          finish <= '1';
99
                          start <= '0';
100
                        end if;
101
                      else -- ERRORgen
102
                      CTL_ERROR <= x"45";
103
                      
104
                    end if;
105
                  end if;
106
                elsif (finish = '1' and start ='0') then
107
                    nextstatus <= finish_mess;
108

109
                end if;  
110
            when finish_mess =>  
111
                  WRITE_ENABLE <= '1';
112
                  CTL_STATE <= "01";-- fertig
113
                  nextstatus <= idle;
114
      end case;
115
end if;
116
end Process;      
117

118
TMP_VAL <= TMP_VAL_1;
119
      
120
end Behavioral;
Gast #3649519
Lesenswert?

A. ZANAM schrieb:
> VAL_TMP muss zum buffer-Block geschoben werden und dann wird gespeichert

VAL_TMP kommt in deinem Code nicht vor, dafür aber TMP_VAL_1, tmpValue 
und TMP_VAL. Da kann man schon mal die Übersicht verlieren.

A. ZANAM schrieb:
> if (bit_count > 0 and bit_count < 8) then
>   tmpValue <= tmpValue(70 downto 0) & DATA_IN;
>   bit_count <= bit_count +1;
>   if (bit_count = 10) then
>      TMP_VAL_1 <= tmpValue;

bit_count muss also zwischen 0 und 8 liegen und gleichzeitig gleich 10 
sein, damit du den Wert an TMP_VAL_1 zuweist? Das wird wohl nicht gut 
funktionieren. Davon abgesehen wird bit_count leider nie größer als 8 
werden.

Lattice User schrieb:
> Was sagt die Simulation?

Genau: simuliere den Code, dann findest du auch ohne Kopfweh wo es 
hängt.
Moderator (Firma: Titel) Persönliche Seite #3650670
Lesenswert?

So einen Zwitter aus Ein- und Zwei-Prozess-Schreibweise habe ich noch 
nirgends gesehen:
1
elsif (rising_edge(CLK)) then -- getaktet...
2
    state <= nextstatus;      -- Zustand übernehmen
3
end if;
4
end Process;
5

6
Process (CLK, DATA_IN) -- BTW: dieser Prozess ist eigentlich nur auf clk sensitiv.
7
begin
8

9
if (rising_edge(CLK)) then    -- nochmal getaktet :-o
10

11
      case state is
12
            when idle =>
13
                ...
14
                if (CTL_TODO = '1' and in_process = '0' and finish = '0') then
15
                    nextstatus <= start_mess;   -- hoppala !!!
16
                end if;
Das gibt einen Takt Latency, der sicher nicht gewollt ist!

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren