OpenCores
URL https://opencores.org/ocsvn/simple_fm_receiver/simple_fm_receiver/trunk

Subversion Repositories simple_fm_receiver

[/] [simple_fm_receiver/] [trunk/] [source/] [fm.c] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 arif_endro
#include <stdio.h>
2
#include <string.h>
3
#include "genpat.h"
4
 
5
char *inttostr(entier)
6
int entier;
7
 {
8
 char *str;
9
 str = (char *) mbkalloc (32 * sizeof (char));
10
 sprintf (str, "%d",entier);
11
 return(str);
12
 }
13
  /*------------------------------*/
14
  /* end of the description       */
15
  /*------------------------------*/
16
 
17
main (int argc, char *argv[])
18
{
19
int i,c;
20
int ks;
21
FILE *f1;
22
char *fname1 = "fm.txt";
23
char  fmin[5000][50];
24
 
25
if (argc > 1 ) {
26
  if (argc == 2) {
27
    fname1 = argv[1];
28
    printf("Using (%s)\n", fname1);
29
  } else {
30
    printf("Usage %s: fm-source.txt\n", argv[0]);
31
    return 0;
32
  }
33
}
34
 
35
if(fname1 && (f1 = fopen(fname1, "rt"))) {
36
  i = 0;
37
  while(fgets(fmin[i],sizeof(fmin[i]),f1) != NULL) {
38
    c = strlen(fmin[i]);
39
    if(fmin[i][c-1] == '\n') fmin[i][c-1] = '\0';
40
    i++;
41
  }
42
  fclose (f1);
43
} else {
44
  fclose (f1);
45
}
46
 
47
ks = i;
48
 
49
DEF_GENPAT("fm");
50
SETTUNIT("ns");
51
 
52
DECLAR (  "clk", ":1", "B", IN , ""           , "" );
53
DECLAR ("reset", ":1", "B", IN , ""           , "" );
54
DECLAR ("fmin" , ":1", "B", IN , " 7 downto 0", "" );
55
DECLAR ("dmout", ":1", "B", OUT, "11 downto 0", "" );
56
DECLAR (  "vss", ":1", "B", IN , ""           , "" );
57
DECLAR (  "vdd", ":1", "B", IN , ""           , "" );
58
 
59
AFFECT ("0", "vss", "0b0");
60
AFFECT ("0", "vdd", "0b1");
61
 
62
AFFECT (  "0","fmin","0x00");
63
AFFECT (  "0","reset","0b1");
64
AFFECT (  "0", "clk", "0b0");
65
AFFECT ("+50", "clk", "0b1");
66
AFFECT ("+50", "clk", "0b0");
67
AFFECT ( "+0","reset","0b0");
68
 
69
for (i = 0; i < ks; i++)
70
{
71
  AFFECT ("+50", "clk", "0b1" );
72
  AFFECT ("+50", "clk", "0b0" );
73
  AFFECT ( "+0","fmin",fmin[i]);
74
}
75
 
76
AFFECT ("+50", "clk", "0b1" );
77
AFFECT ("+50", "clk", "0b0" );
78
AFFECT ( "+0","fmin", "0x00");
79
 
80
for (; i <1100; i++)
81
{
82
  AFFECT ("+50", "clk", "0b1" );
83
  AFFECT ("+50", "clk", "0b0" );
84
}
85
 
86
AFFECT ("+50", "clk", "0b1");
87
 
88
SAV_GENPAT ();
89
}
90
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.