end entity parser;
architecture beh of parser is
- type PARSER_STATE is (SIDLE, SREAD_NEWNUMBER, SREAD_NEXTBYTE,
- SREAD_CALCNUMBER1, SREAD_CALCNUMBER2, SCALC_1, SCALC_14, SCALC_15, SCALC_2, SWRITE_CHAR1,
- SWRITE_CHAR2, SDONE, SERROR1, SERROR2);
+ type PARSER_STATE is (SIDLE, SREAD_NEWNUMBER, SREAD_SPACE1_2,
+ SREAD_SPACE1_3, SREAD_SPACE2, SREAD_SPACE3, SREAD_OP1, SREAD_OP2,
+ SREAD_NEXTBYTE, SREAD_CALCNUMBER1, SREAD_CALCNUMBER2, SCALC_1, SCALC_14,
+ SCALC_15, SCALC_2, SWRITE_CHAR1, SWRITE_CHAR2, SDONE, SERROR1, SERROR2);
signal state_int, state_next : PARSER_STATE;
signal z_int, z_next, strich_int, strich_next, wtmp_int, wtmp_next : csigned;
signal punkt_int, punkt_next : csigned;
signal op1_int, op1_next : csigned;
signal op2_int, op2_next : csigned;
signal do_calc_int, do_calc_next : std_logic;
+ signal goto_calcn1, goto_op1, goto_space3 : std_logic;
begin
p_write <= p_write_int;
p_rget <= p_rget_int;
-- next state
process(state_int, do_it, p_rdone, p_wdone, p_read, aktop_int, strich_int,
- punkt_int, calc_done, wtmp_int, opp_int)
+ punkt_int, calc_done, wtmp_int, opp_int, goto_calcn1, goto_op1,
+ goto_space3)
begin
state_next <= state_int;
state_next <= SREAD_NEWNUMBER;
end if;
when SREAD_NEWNUMBER =>
- state_next <= SREAD_NEXTBYTE;
+ state_next <= SREAD_SPACE1_2;
+ when SREAD_SPACE1_2 =>
+ if p_rdone = '1' then
+ state_next <= SREAD_SPACE2;
+ end if;
+ when SREAD_SPACE1_3 =>
+ if p_rdone = '1' then
+ state_next <= SREAD_SPACE3;
+ end if;
+ when SREAD_SPACE2 | SREAD_SPACE3 =>
+ if p_rdone = '0' then
+ if goto_calcn1 = '0' then
+ case state_int is
+ when SREAD_SPACE2 => state_next <= SREAD_SPACE1_2;
+ when SREAD_SPACE3 => state_next <= SREAD_SPACE1_3;
+ when others => assert(false) report "wtf @ state2";
+ end case;
+ end if;
+ end if;
+ if goto_calcn1 = '1' then
+ case state_int is
+ when SREAD_SPACE2 => state_next <= SREAD_NEXTBYTE;
+ when SREAD_SPACE3 => state_next <= SREAD_OP1;
+ when others => assert(false) report "wtf @ state1";
+ end case;
+ end if;
when SREAD_NEXTBYTE =>
if p_rdone = '1' then
state_next <= SREAD_CALCNUMBER1;
end if;
when SREAD_CALCNUMBER1 =>
- state_next <= SREAD_CALCNUMBER2;
- when SREAD_CALCNUMBER2 =>
+ if goto_op1 = '1' then
+ state_next <= SREAD_OP1;
+ elsif goto_space3 = '1' then
+ state_next <= SREAD_SPACE3;
+ else
+ state_next <= SREAD_CALCNUMBER2;
+ end if;
+ when SREAD_OP1 =>
+ state_next <= SREAD_OP2;
+ when SREAD_OP2 =>
if p_rdone = '0' then
if aktop_int /= ALU_NOP then
state_next <= SCALC_1;
- else
- state_next <= SREAD_NEXTBYTE;
end if;
end if;
+ when SREAD_CALCNUMBER2 =>
+ if p_rdone = '0' then
+ state_next <= SREAD_NEXTBYTE;
+ end if;
when SCALC_1 =>
if calc_done = '1' then
case opp_int is
op1_next <= op1_int;
op2_next <= op2_int;
do_calc_next <= '0';
+ goto_calcn1 <= '0';
+ goto_op1 <= '0';
+ goto_space3 <= '0';
case state_int is
when SIDLE =>
rbyte_next <= (others => '0');
p_write_next <= (others => '0');
aktop_next <= ALU_NOP;
- when SREAD_NEXTBYTE =>
+ when SREAD_NEXTBYTE | SREAD_SPACE1_2 | SREAD_SPACE1_3 =>
p_rget_next <= '1';
+ when SREAD_SPACE2 | SREAD_SPACE3 =>
+ case p_read is
+ when x"20" =>
+ null;
+ when others =>
+ goto_calcn1 <= '1';
+ p_rget_next <= '1';
+ end case;
+
when SREAD_CALCNUMBER1 =>
+ case p_read is
+ -- '+', '-', '*', '/'
+ when x"2B" | x"2D" | x"2A" | x"2F" | x"00" =>
+ goto_op1 <= '1';
+ p_rget_next <= '1';
+
+ -- ' '
+ when x"20" =>
+ goto_space3 <= '1';
+ p_rget_next <= '1';
+
+ when others =>
+ -- TODO: check auf overflow
+ multmp := (z_int * 10) + hbyte2csigned(p_read);
+ z_next <= multmp((CBITS-1) downto 0);
+ end case;
+ when SREAD_CALCNUMBER2 | SREAD_OP2 =>
+ null;
+ when SREAD_OP1 =>
case p_read is
-- '+'
when x"2B" =>
when x"00" =>
aktop_next <= ALU_DONE;
- when others =>
- -- TODO: check auf overflow
- multmp := (z_int * 10) + hbyte2csigned(p_read);
- z_next <= multmp((CBITS-1) downto 0);
+ -- TODO: err!
+ when others => assert(false) report "TODO: ...";
end case;
- when SREAD_CALCNUMBER2 =>
- null;
+
when SCALC_1 =>
case opp_int is