*--------1---------2---------3---------4---------5---------6---------7-- * * This module creates a template for the VHDL code. * subroutine GENCODE(Index, HowMany, MaskNumExp, MSKstore) * initialize user variables *---------------------------------- integer Index, HowMany, MaskNumExp integer Numb, Hund, Tens, Unit integer Pattern(4) integer I, J, K, L character*14 Signal, B(32) character*10 FName, A(32) character*5 MSKstore(MaskNumExp, 12), Word, Null character*2 Prefix(12), Point character*1 Hit(8) parameter (Null = '+0000') data Hit/'1', '2', '3','4', '5', '6', '7', '8'/ data Prefix/'00', '01', '02', '03', '04', '05', + '10', '11', '12', '13', '14', '15'/ * initialize values *---------------------------------- FName = Prefix(Index)//'soft.vhd' open(unit = 10, file = FName, status = "NEW") FName = Prefix(Index)//'firm.vhd' open(unit = 20, file = FName, status = "NEW") * event processing *---------------------------------- do I = 1, HowMany if (MSKstore(I, Index).ne.Null) then Word = MSKstore(I, Index) * mask number as a character *---------------------------------- Hund = (I - 1) / 100 Tens = ((I - 1) - 100 * Hund) / 10 Unit = (I - 1) - 100 * Hund - 10 * Tens if (Hund.gt.0) then Signal = 'Mask0('//char(48 + Hund)// + char(48 + Tens)// + char(48 + Unit)//') <= ' else if (Tens.gt.0) then Signal = 'Mask0('//char(48 + Tens)// + char(48 + Unit)//') <= ' else Signal = 'Mask0('//char(48 + Unit)//') <= ' end if * default firm mask *---------------------------------- do J = 1, 32 Tens = (J - 1) / 10 Unit = (J - 1) - 10 * Tens if (Tens.gt.0) then Point = char(48 + Tens)//char(48 + Unit) else Point = char(48 + Unit) end if B(J) = 'not Tdata0('//Point//')' end do do J = 1, 4 Pattern(J) = 0 end do do J = 1, 4 K = J + 1 do L = 1, 8 if (Word(K:K).eq.Hit(L)) Pattern(J) = (J - 1)*8 + L end do end do * pad number as a character *---------------------------------- do J = 1, 4 if (Pattern(J).gt.0) then Tens = (Pattern(J) - 1) / 10 Unit = (Pattern(J) - 1) - 10 * Tens if (Tens.gt.0) then Point = char(48 + Tens)//char(48 + Unit) else Point = char(48 + Unit) end if * Soft masks *---------------------------------- if (Word(1:1).eq.'-') A(Pattern(J)) = 'Tdata0('//Point//')' * Firm masks *---------------------------------- if (Word(1:1).eq.'+') B(Pattern(J)) = ' Tdata0('//Point//')' end if end do * Data output *---------------------------------- if (Word(1:1).eq.'-') then if (Pattern(4).eq.0) then write(10,*) Signal//A(Pattern(3))//' and '// + A(Pattern(2))//' and '// + A(Pattern(1))//';' else if (Pattern(3).eq.0) then write(10,*) Signal//A(Pattern(4))//' and '// + A(Pattern(2))//' and '// + A(Pattern(1))//';' else if (Pattern(2).eq.0) then write(10,*) Signal//A(Pattern(4))//' and '// + A(Pattern(3))//' and '// + A(Pattern(1))//';' else if (Pattern(1).eq.0) then write(10,*) Signal//A(Pattern(4))//' and '// + A(Pattern(3))//' and '// + A(Pattern(2))//';' else write(10,*) Signal//A(Pattern(4))//' and '// + A(Pattern(3))//' and '// + A(Pattern(2))//' and '// + A(Pattern(1))//';' end if end if if (Word(1:1).eq.'+') then write(20,*) Signal//B(32)//' and '//B(31)//' and ' + //B(30)//' and '//B(29)//' and ' write(20,*) ' '//B(28)//' and '//B(27)//' and ' + //B(26)//' and '//B(25)//' and ' write(20,*) ' '//B(24)//' and '//B(23)//' and ' + //B(22)//' and '//B(21)//' and ' write(20,*) ' '//B(20)//' and '//B(19)//' and ' + //B(18)//' and '//B(17)//' and ' write(20,*) ' '//B(16)//' and '//B(15)//' and ' + //B(14)//' and '//B(13)//' and ' write(20,*) ' '//B(12)//' and '//B(11)//' and ' + //B(10)//' and '//B(9)//' and ' write(20,*) ' '//B(8)//' and '//B(7)//' and ' + //B(6)//' and '//B(5)//' and ' write(20,*) ' '//B(4)//' and '//B(3)//' and ' + //B(2)//' and '//B(1)//';' write(20,*)'' end if end if end do close(10) close(20) return end