forked from epall/Computer.Build
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
89 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace ComputerBuild\Vhdl; | ||
|
||
/** | ||
* Symbol | ||
* | ||
* @author Luis Cordova <cordoval@gmail.com> | ||
*/ | ||
class Symbol | ||
{ | ||
protected $expression; | ||
|
||
public function __construct($expression) | ||
{ | ||
$this->expression = $expression; | ||
} | ||
|
||
public function __toString() | ||
{ | ||
return $this->expression; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Tests\ComputerBuild\Vhdl; | ||
|
||
use ComputerBuild\Vhdl\Assign; | ||
|
||
class AssignTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testAssignTwoArgumentsShouldAssignFirstTargetSecondExpression() | ||
{ | ||
// Assign(arg0, arg1) | ||
// arg0 <= std_logic_vector("arg1") | ||
$assignStatement = new Assign(array('output', '0101001')); | ||
$this->assertEquals("output <= \"0101001\"", $assignStatement->generate()); | ||
} | ||
|
||
public function testAssignFourArgumentsShouldSplitTwoAssignments() | ||
{ | ||
// Assign(arg0, arg1, arg2, arg3) | ||
// output(7 downto 0) <= std_logic_vector("00010001") | ||
$assignStatement = new Assign(array('output', '7 downto 0', 'std_logic_vector', '00010001')); | ||
$this->assertEquals("output(7 downto 0) <= std_logic_vector(\"00010001\")", $assignStatement->generate()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Tests\ComputerBuild\Vhdl; | ||
|
||
use ComputerBuild\Vhdl\Type; | ||
|
||
/** | ||
* @author Luis Cordova <cordoval@gmail.com> | ||
* @author Raul Rodriguez <raulrodriguez782@gmail.com> | ||
*/ | ||
class TypeTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testTypeStatement() | ||
{ | ||
$typeStatement = new Type('type_enum', array('a', 'b', 'c')); | ||
$this->assertEquals('TYPE type_enum IS (a, b, c);', $typeStatement->line()); | ||
} | ||
} |